Option Strict Off
Option Explicit On
Imports VB = Microsoft.VisualBasic
Friend Class frmSettings
	Inherits System.Windows.Forms.Form 'Declares that all variables must be defined before use.
	'Declare APIs that enable you to search for a directory name
	'UPGRADE_WARNING: Structure BrowseInfo may require marshalling attributes to be passed as an argument in this Declare statement. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="C429C3A5-5D47-4CD9-8F51-74A1616405DC"'
	Private Declare Function SHBrowseForFolder Lib "shell32" (ByRef lpBI As BrowseInfo) As Integer
	Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Integer, ByVal lpBuffer As String) As Integer
	Private Declare Function lstrcat Lib "kernel32"  Alias "lstrcatA"(ByVal lpString1 As String, ByVal lpString2 As String) As Integer
	
	Private Structure BrowseInfo
		Dim hWndOwner As Integer
		Dim pIDLRoot As Integer
		Dim pszDisplayName As Integer
		Dim lpszTitle As Integer
		Dim ulFlags As Integer
		Dim lpfnCallback As Integer
		Dim lParam As Integer
		Dim iImage As Integer
	End Structure
	
	'Declare used to run windows commands, used to open web browser so user can visit website.
	Private Declare Function ShellExecute Lib "shell32.dll"  Alias "ShellExecuteA"(ByVal hwnd As Integer, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Integer) As Integer
	
	
	
	
	
	Private Sub frmSettings_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
		
		
		'UPGRADE_NOTE: The Following line was commented to give the same effect as VB6. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="1C44C272-DA6E-4A2A-BDC5-9A27F0D03D31"'
		'Me.FormBorderStyle = 0
		'UPGRADE_ISSUE: Form property frmSettings.ScaleMode is not supported. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="8027179A-CB3B-45C0-9863-FAA1AF983B59"'
        'frmSettings.ScaleMode = 3 'Set scalemode to pixels
		Me.Width = VB6.TwipsToPixelsX(960 * VB6.TwipsPerPixelX)
		Me.Height = VB6.TwipsToPixelsY(710 * VB6.TwipsPerPixelY)
		Me.Left = VB6.TwipsToPixelsX((VB6.PixelsToTwipsX(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width) / 2) - ((960 * VB6.TwipsPerPixelX) / 2)) 'Set the window to be in the middle of the screen
		Me.Top = VB6.TwipsToPixelsY((VB6.PixelsToTwipsY(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height) / 2) - (((710 / 2) + 28) * VB6.TwipsPerPixelY)) 'Set the window raised up slightly. So it is better positioned when running at 1024 x 768
		
		'UPGRADE_ISSUE: PictureBox property picFacia2.ScaleMode was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
        'picFacia2.ScaleMode = 3
		'UPGRADE_ISSUE: PictureBox property picFacia2.AutoSize was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
		picFacia2.AutoSize = True : picFacia2.Left = 0 : picFacia2.Top = 0
		'UPGRADE_ISSUE: PictureBox property picFacia2.AutoRedraw was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
        'picFacia2.AutoRedraw = True : picFacia2.BorderStyle = System.Windows.Forms.BorderStyle.None
		picFacia2.Visible = True
		picFacia2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None
		'UPGRADE_WARNING: Picture has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
		picFacia2.BackgroundImage = System.Drawing.Image.FromFile(My.Application.Info.DirectoryPath & "\Skins\" & Skin & "_Settings_S.jpg") 'Setup the correct picture size etc.
		
		'UPGRADE_WARNING: Control property picFacia2.Parent was upgraded to picFacia2.FindForm which has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="DFCDE711-9694-47D7-9C50-45A99CD8E91E"'
		SetWindowRgn(picFacia2.FindForm.Handle.ToInt32, RegionSettings, True) 'Set the region of the Settings box outside which nothing will be displayed. The region has been
		
		Call SetUpSettingsBoxContents()
		
		Me.Show()
		
	End Sub
	Private Sub cmdXSheet_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdXSheet.Click 'Select the X sheet from disk
		'UPGRADE_WARNING: Filter has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
		CommonDialog2Open.Filter = "Select Existing File (*.txt) | *.txt" 'Set the common dialog box to only show .txt files
		CommonDialog2Open.InitialDirectory = SavePath 'Set the directory to look in as the current directory
		CommonDialog2Open.ShowDialog() 'Display the file dialog to the user
		'UPGRADE_WARNING: Dir has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
		If Dir(CommonDialog2Open.FileName) <> "" Then
			txtXSheet.Text = CommonDialog2Open.FileName
		End If 'if the file exists set the variable
		If txtXSheet.Text = "" Or Len(txtXSheet.Text) = 0 Then txtXSheet.Text = "No X Sheet Selected" 'Filename may be nothing (user has hit cancel)
		
	End Sub
	Private Sub cmdSoundTrack_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdSoundTrack.Click 'Select the sound file from disk
		' ComDlg.filter = "HTML Pages (*.htm, *.html)|*.htm;*.html|All Files (*.*)|*.*"
		'UPGRADE_WARNING: Filter has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
		CommonDialog2Open.Filter = "Select Existing File (*.mp3, *.wav) | *.mp3; *.wav" 'Set the common dialog box to only show .txt files
		CommonDialog2Open.InitialDirectory = SavePath 'Set the directory to look in as the current directory
		CommonDialog2Open.ShowDialog() 'Display the file dialog to the user
		txtSoundTrack.Text = CommonDialog2Open.FileName
		'UPGRADE_WARNING: Dir has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
		If Dir(CommonDialog2Open.FileName) <> "" Then
			txtSoundTrack.Text = CommonDialog2Open.FileName
		End If 'if the file exists set the variable
		If txtSoundTrack.Text = "" Or Len(txtSoundTrack.Text) = 0 Then txtSoundTrack.Text = "No Soundtrack Selected" 'Filename may be nothing (user has hit cancel)
	End Sub
	Private Sub cmdSelectBackground_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdSelectBackground.Click 'Select the background for the Chroma Keying
		'UPGRADE_WARNING: Filter has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
		CommonDialog2Open.Filter = "Select Background Image (*.bmp, *.jpg) | *.bmp; *.jpg" 'Set the common dialog box to only show .bmp and .jpg files
		CommonDialog2Open.InitialDirectory = SavePath 'Set the directory to look in as the current directory
		CommonDialog2Open.ShowDialog() 'Display the file dialog to the user
		txtBackground.Text = CommonDialog2Open.FileName
		'UPGRADE_WARNING: Dir has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
		If Dir(CommonDialog2Open.FileName) <> "" Then
			txtBackground.Text = CommonDialog2Open.FileName
		End If 'if the file exists set the variable
		If txtBackground.Text = "" Or Len(txtBackground.Text) = 0 Then txtBackground.Text = "No Background Image Selected" 'Filename may be nothing (user has hit cancel)
	End Sub
	
	
	Public Sub SetUpSettingsBoxContents() 'sets up the contents of the settings window
		'Set up the form buttons and labels
		Me.txtProjName.Text = ProjName
		Me.txtSaveDir.Text = SavePath
		Me.txtXSheetOffset.Text = CStr(XSheetOffset)
		Me.txtXSheet.Text = XSheetName
		Me.txtSoundTrack.Text = SoundTrackName
		
		Me.txtCaptureSnd.Text = CaptureSound
		
		If SoundsOnOff = True Then 'check the variable to see if the sound clickbox is on or off
			Me.chkSoundSwitch.CheckState = System.Windows.Forms.CheckState.Checked
		Else
			Me.chkSoundSwitch.CheckState = System.Windows.Forms.CheckState.Unchecked
		End If
		
		If MouthShapeOnOff = True Then 'check the variable to see if the mouthshape should be displayed
			Me.chkMouthShapes.CheckState = System.Windows.Forms.CheckState.Checked
		Else
			Me.chkMouthShapes.CheckState = System.Windows.Forms.CheckState.Unchecked
		End If
		
		Me.txtCaptureQuality.Text = Str(CaptureQuality)
		Me.txtFrameDpth.Text = Str(FrameAvgDepth)
		Me.txtFrameDel.Text = Str(FrameAvgDelay)
		Me.txtFPS.Text = Str(FPS)
		
		If SafeAreaYesNo = True Then 'Check variable to see if the user wants to display a safe area rectangle
			Me.chkSafeArea.CheckState = System.Windows.Forms.CheckState.Checked
		Else
			Me.chkSafeArea.CheckState = System.Windows.Forms.CheckState.Unchecked
		End If
		
		Me.txtSafeAreaWidth.Text = CStr(SafeAreaWidth)
		
		Me.txtSafeAreaHeight.Text = CStr(SafeAreaHeight)
		
		Me.picSafeAreaColour.BackColor = System.Drawing.ColorTranslator.FromOle(SafeAreaColour)
		
		If OutputBmpFramesYesNo = True Then 'check the variable to see if the individual frames should be on or off
			Me.chkIndBmps.CheckState = System.Windows.Forms.CheckState.Checked
		Else
			Me.chkIndBmps.CheckState = System.Windows.Forms.CheckState.Unchecked
		End If
		
		If OutputJpgFramesYesNo = True Then 'check the variable to see if the individual frames should be on or off
			Me.chkIndJpegs.CheckState = System.Windows.Forms.CheckState.Checked
		Else
			Me.chkIndJpegs.CheckState = System.Windows.Forms.CheckState.Unchecked
		End If
		
		Me.txtJpegQuality.Text = Str(JpegQuality)
		
		If OutputTifFramesYesNo = True Then 'check the variable to see if the individual frames should be on or off
			Me.chkIndTifs.CheckState = System.Windows.Forms.CheckState.Checked
		Else
			Me.chkIndTifs.CheckState = System.Windows.Forms.CheckState.Unchecked
		End If
		
		If OutputGifFramesYesNo = True Then 'check the variable to see if the individual frames should be on or off
			Me.chkIndGifs.CheckState = System.Windows.Forms.CheckState.Checked
		Else
			Me.chkIndGifs.CheckState = System.Windows.Forms.CheckState.Unchecked
		End If
		
		If OutputPngFramesYesNo = True Then 'check the variable to see if the individual frames should be on or off
			Me.chkIndPngs.CheckState = System.Windows.Forms.CheckState.Checked
		Else
			Me.chkIndPngs.CheckState = System.Windows.Forms.CheckState.Unchecked
		End If
		
		If ChromaType = "Off" Then
			optOff.Checked = True
			ChromaKeyingYesNO = False
		End If
		
		If ChromaType = "Red" Then
			optRed.Checked = True
			ChromaKeyingYesNO = True
		End If
		
		If ChromaType = "Green" Then
			OptGreen.Checked = True
			ChromaKeyingYesNO = True
		End If
		
		If ChromaType = "Blue" Then
			optBlue.Checked = True
			ChromaKeyingYesNO = True
		End If
		
		Me.txtBackground.Text = ChromaBackground
		
		If FrameNumberStampYesNo = True Then 'check the variable to see if the individual frames stamp should be on or off
			Me.chkFrameStamp.CheckState = System.Windows.Forms.CheckState.Checked
		Else
			Me.chkFrameStamp.CheckState = System.Windows.Forms.CheckState.Unchecked
		End If
		
		Me.txtLoopLength.Text = Str(LoopLength)
		Me.txtFramesPerClick.Text = Str(NumFramesPerClick)
		
		If ShutterMacroYesNo = True Then 'check the variable to see if the user has previously had macros on or off
			Me.chkCaptureMacro.CheckState = System.Windows.Forms.CheckState.Checked
		Else
			Me.chkCaptureMacro.CheckState = System.Windows.Forms.CheckState.Unchecked
		End If
		If ErrorLoggingYesNO = True Then 'check the variable to see if the user wants to output an error logging text file
			Me.chkErrorLogging.CheckState = System.Windows.Forms.CheckState.Checked
		Else
			Me.chkErrorLogging.CheckState = System.Windows.Forms.CheckState.Unchecked
		End If
		Me.txtMacroFile.Text = MacroFilename
		
		Me.txtTimeLapseDelay.Text = Str(Int(TimeLapseDelay / 1000)) 'Display the current time lapse interval in the text box
		
		'Set Hotkey Text boxes to show the ascii codes loaded in from user settings file
		Me.txtHotkey01.Text = CStr(Ascii01)
		Me.txtHotkey02.Text = CStr(Ascii02)
		Me.txtHotkey03.Text = CStr(Ascii03)
		Me.txtHotkey04.Text = CStr(Ascii04)
		Me.txtHotkey05.Text = CStr(Ascii05)
		Me.txtHotkey06.Text = CStr(Ascii06)
		Me.txtHotkey07.Text = CStr(Ascii07)
		Me.txtHotkey08.Text = CStr(Ascii08)
		Me.txtHotkey09.Text = CStr(Ascii09)
		Me.txtHotkey10.Text = CStr(Ascii10)
		Me.txtHotkey11.Text = CStr(Ascii11)
		Me.txtHotkey12.Text = CStr(Ascii12)
		Me.txtHotkey13.Text = CStr(Ascii13)
		Me.txtHotKey14.Text = CStr(Ascii14)
		Me.txtHotKey15.Text = CStr(Ascii15)
		Me.txtHotkey16.Text = CStr(Ascii16)
		Me.txtHotkey17.Text = CStr(Ascii17)
		Me.txtHotkey18.Text = CStr(Ascii18)
	End Sub
	Private Sub cmdProjectName_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdProjectName.Click 'Choose an existing .avi file to work on
		Dim TempFileName1 As String
		Dim TempFileName2 As String
		Dim ResolutionCheckX As Integer
		Dim ResolutionCheckY As Integer
		Dim Cnt As Integer
		
		'UPGRADE_WARNING: Filter has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
		CommonDialog2Open.Filter = "Select Existing File (*.avi) | *.avi" 'Set the common dialog box to only show .avi files
		CommonDialog2Open.InitialDirectory = SavePath 'Set the directory to look in as the current directory
		CommonDialog2Open.ShowDialog() 'Display the file dialog to the user
		
		'Now try to open the file for playing just to check it is valid
		On Error GoTo ProblemsOpeningFile
		If OpenDShowPlayBack((CommonDialog2Open.FileName), (frmCapture.picPlayBack)) = False Then 'try to open it and watch for an error
			Call MsgBox("The file is corrupt and cannot be used for animation", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "Helium Frog Animator")
			RemoveDShowPlayBack() 'close it again
			FunctionOK = OpenDShowPlayBack(SavePath & ProjName & ".avi", (frmCapture.picPlayBack)) 'Open up the old video as we know this works. The user may now exit back to this one
			Exit Sub
		End If
		' RemoveDShowPlayBack                                                     'close it again
		
		'Check the resolution of the image matches the current camera settings
		FileOpen(18, CommonDialog2Open.FileName, OpenMode.Binary, OpenAccess.Read)
		'UPGRADE_WARNING: Get was upgraded to FileGet and has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
		FileGet(18, ResolutionCheckX, 184 + 1) 'Get the resolution of the existing file
		'UPGRADE_WARNING: Get was upgraded to FileGet and has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
		FileGet(18, ResolutionCheckY, 188 + 1) 'Get the resolution of the existing file
		FileClose(18)
		
		If (ResolutionCheckX <> CaptureWidth) Or (ResolutionCheckY <> CaptureHeight) Then
			Call MsgBox("I cannot load this file because the image resolution is" & Chr(13) & Chr(10) & ResolutionCheckX & " X " & ResolutionCheckY & " and your source device is set at " & CaptureWidth & " X " & CaptureHeight & Chr(13) & Chr(10) & "To work with this file, restart Helium Frog and reset your source device to " & ResolutionCheckX & " X " & ResolutionCheckY, MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "Helium Frog Animator")
			Exit Sub 'the newly selected file is at a different resolution to the source device so dont load it
		End If
		
		
		TempFileName1 = StrReverse(CommonDialog2Open.FileName) 'Reverse the filename selected by the user
		
		'Extract the filename
		For Cnt = 1 To Len(TempFileName1) 'Loop through the filename to find the first instance of \ to extract just the filename
			If Mid(TempFileName1, Cnt, 1) <> "\" Then
				TempFileName2 = TempFileName2 & Mid(TempFileName1, Cnt, 1) 'Extract the file name
			Else
				GoTo FoundBackSlash 'A \ has been found, so exit the loop
			End If
		Next Cnt
		Call MsgBox("Not a valid filename", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "Helium Frog Animator")
		Exit Sub
FoundBackSlash: 
		
		'Extract the directory
		For Cnt = 1 To Len(TempFileName1) 'Loop through the filename to find the first instance of \ to extract just the filename
			If Mid(TempFileName1, 1, 1) <> "\" Then 'Check if the first character of the reversed string is a \
				TempFileName1 = Mid(TempFileName1, 2) 'If not truncate the first character off the string
			Else
				GoTo FoundBackSlash1 'A \ has been as the first character, so exit the loop
			End If
		Next Cnt
		Call MsgBox("Not a valid directory", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "Helium Frog Animator")
		Exit Sub
FoundBackSlash1: 
		
		TempFileName2 = Mid(TempFileName2, 5) 'Remove the .avi (actually the iva.) from the start of the reversed name
		txtProjName.Text = StrReverse(TempFileName2) 'Save the filename in the text box
		txtSaveDir.Text = StrReverse(TempFileName1) 'Save the directory in the text box
		Exit Sub
		
ProblemsOpeningFile: 
		Call MsgBox("The file you have chosen seems to be corrupt, I cannot use it for animation.", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "Helium Frog Animator")
	End Sub
	Private Sub cmdNew_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdNew.Click
		
		'Generate the output filename
		If CDbl(GenerateFilename(SavePath)) = 0 Then 'The function has failed to generate a valid filename
			Call MsgBox("I could not generate a filename in the specified directory.", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "Helium Frog Animator")
			Exit Sub 'Exit the Subroutine
		End If
		ValidFilename = StrReverse(ValidFilename) 'Reverse the name
		ValidFilename = Mid(ValidFilename, 5) 'Remove the .avi (actually the iva.) from the start of the reversed name
		ValidFilename = StrReverse(ValidFilename) 'Reverse the name back again
		Me.txtProjName.Text = ValidFilename 'Place the new name in the text box
	End Sub
	Private Sub cmdCaptureSnd_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdCaptureSnd.Click
		Dim TempFileName1 As String
		Dim TempFileName2 As String
		Dim Cnt As Integer
		
		'UPGRADE_WARNING: Filter has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
		CommonDialog2Open.Filter = "Select Wave File (*.wav) | *.wav" 'Set the common dialog box to only show .wav files
		CommonDialog2Open.InitialDirectory = My.Application.Info.DirectoryPath & "\Sounds\" 'Set the initial directory to the Sounds directory
		CommonDialog2Open.ShowDialog() 'Display the file dialog to the user
		TempFileName1 = StrReverse(CommonDialog2Open.FileName) 'Reverse the filename selected by the user
		For Cnt = 1 To Len(TempFileName1) 'Loop through the filename to find the first instance of \ to extract just the filename
			If Mid(TempFileName1, Cnt, 1) <> "\" Then
				TempFileName2 = TempFileName2 & Mid(TempFileName1, Cnt, 1)
			Else
				GoTo FoundBackSlash 'A \ has been found, so exit the loop
			End If
		Next Cnt
FoundBackSlash: 
		TempFileName2 = Mid(TempFileName2, 5) 'Remove the .wav (actually the vaw.) from the start of the reversed name
		CaptureSound = StrReverse(TempFileName2) 'Reverse the filename back to the correct way round and store it in the variable
		txtCaptureSnd.Text = CaptureSound 'Display the filename in the box
	End Sub
	Private Sub cmdSaveDir_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdSaveDir.Click
		'Opens a Treeview control that displays the directories in a computer
		
		Dim lpIDList As Integer
		Dim sBuffer As String
		Dim szTitle As String
		Dim tBrowseInfo As BrowseInfo
		
		szTitle = "Select Storage Directory"
		
		tBrowseInfo.hWndOwner = Me.Handle.ToInt32
		tBrowseInfo.lpszTitle = lstrcat(szTitle, "")
		tBrowseInfo.ulFlags = 3
		
		
		lpIDList = SHBrowseForFolder(tBrowseInfo)
		
		If (lpIDList) Then
			sBuffer = Space(260)
			SHGetPathFromIDList(lpIDList, sBuffer)
			sBuffer = VB.Left(sBuffer, InStr(sBuffer, vbNullChar) - 1)
			If VB.Right(sBuffer, 1) <> "\" Then sBuffer = sBuffer & "\"
			txtSaveDir.Text = sBuffer
		End If
	End Sub
	Private Sub cmdSelectSafeAreaColour_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdSelectSafeAreaColour.Click 'The button to select the safe area rectangle border colour
		Me.CommonDialogColourColor.ShowDialog()
		Me.picSafeAreaColour.BackColor = System.Drawing.ColorTranslator.FromOle(CInt(System.Drawing.ColorTranslator.ToOle(Me.CommonDialogColourColor.Color)))
		SafeAreaColour = CInt(System.Drawing.ColorTranslator.ToOle(Me.CommonDialogColourColor.Color))
	End Sub
	
	Private Sub picFacia2_MouseUp(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.MouseEventArgs) Handles picFacia2.MouseUp
		Dim Button As Short = eventArgs.Button \ &H100000
		Dim Shift As Short = System.Windows.Forms.Control.ModifierKeys \ &H10000
		Dim X As Single = eventArgs.X
		Dim Y As Single = eventArgs.Y 'Mouse button has been released over the settings form
		If ActiveWindowIs <> "SettingsWindow" Then Exit Sub 'If the settings window is not active, dont action any buttons
		
		If Button = VB6.MouseButtonConstants.LeftButton Then 'The mouse button is the left button
			Red = 0 : Green = 0 : Blue = 0 'reset the rgb values
			Call GetCursorPos(MousePoint) 'Get the screen position of the cursor
			Call ScreenToClient(Me.picFacia2.Handle.ToInt32, MousePoint) 'Modify values so they are relative to top left of settings window
			PixCol = GetPixel(Hotspot_Settings, MousePoint.X, MousePoint.Y) 'Get the relative colour at the mouse point of the hotspot image in memory
			Red = PixCol And &HFF : Green = CShort(PixCol And &HFF00) / 256 : Blue = CShort(PixCol And &HFF0000) / 65535 'Get the value of each color byte (rgb)
			If Red = 85 And Green = 129 And Blue = 9 Then
				ErrorCodeNo = "00.00" 'Tell the program it is a normal exit
				Call ExitProgram() 'You have released the quit button on the settings form
			End If
			If Red = 206 And Green = 185 And Blue = 245 Then Call LeaveSettings() 'You have released the Continue Button on the settings for
		End If
	End Sub
	
	Private Sub cmdSelectMacro_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdSelectMacro.Click 'The select button to select the macro file
		'UPGRADE_WARNING: Filter has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
		CommonDialog3Open.Filter = "Select Macro File (*.txt) | *.txt" 'Set the common dialog box to only show .txt files
		CommonDialog3Open.InitialDirectory = My.Application.Info.DirectoryPath & "\Macros\" 'Set the initial directory to the Macros directory
		CommonDialog3Open.ShowDialog() 'Display the file dialog to the user
		txtMacroFile.Text = CommonDialog3Open.FileName 'Display the filename in the text box
	End Sub
	Private Sub lblVisitHeliumFrog_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles lblVisitHeliumFrog.Click 'This is a link to the Helium Frog website
		ShellExecute(1, "open", "http://www.HeliumFrog.com", "", "", 1)
	End Sub
	Private Sub lblUserGuide_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles lblUserGuide.Click 'This is a link to the Online User Guide
		ShellExecute(1, "open", "http://myweb.tiscali.co.uk/martincprice/Helium_Frog/helium_frog_documentation/heliumfrogguide.html", "", "", 1)
	End Sub
	
	Private Sub LeaveSettings() 'The user wants to exit from the settings window and return to the main program
		
		
		If (Int(Val(Me.txtFPS.Text)) > 30) Or (Int(Val(Me.txtFPS.Text)) < 1) Then 'Check the frames per second value entered by the user
			Call MsgBox("Frames/Second value must be between 1 and 30", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "Helium Frog Animator")
			Exit Sub
		End If
		If (Int(Val(Me.txtTimeLapseDelay.Text)) > 3600) Or (Int(Val(Me.txtTimeLapseDelay.Text)) < 1) Then 'Check the timelapse is within range
			Call MsgBox("Time Lapse interval must be between 1 and 3600 seconds", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "Helium Frog Animator")
			Exit Sub
		End If
		If (Int(Val(Me.txtFrameDpth.Text)) > 10) Or (Int(Val(Me.txtFrameDpth.Text)) < 1) Then 'Check the frame averaging number of frames entered by the user
			Call MsgBox("Frame averaging must be between 1 and 10 frames", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "Helium Frog Animator")
			Exit Sub
		End If
		If (Int(Val(Me.txtFrameDel.Text)) > 500) Or (Int(Val(Me.txtFrameDel.Text)) < 1) Then 'Check the frame averaging delay between frames entered by the user
			Call MsgBox("Frame averaging time between frames must be between 1 and 500 milliseconds", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "Helium Frog Animator")
			Exit Sub
		End If
		If (Int(Val(Me.txtXSheetOffset.Text)) > 100000) Or (Int(Val(Me.txtXSheetOffset.Text)) < 0) Then 'Check the xsheet offset entered by the user
			Call MsgBox("X sheet offset value must be between 0 and 100000 frames", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "Helium Frog Animator")
			Exit Sub
		End If
		'UPGRADE_WARNING: Dir has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
		If Dir(My.Application.Info.DirectoryPath & "\Sounds\" & Me.txtCaptureSnd.Text & ".wav") = "" Then 'Check that the sound file exists
			Call MsgBox("Sound File - " & Me.txtCaptureSnd.Text & ".wav" & " cannot be found.", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "Helium Frog Animator")
			Exit Sub
		End If
		If (Int(Val(Me.txtLoopLength.Text)) > 500) Or (Int(Val(Me.txtLoopLength.Text)) < 5) Then 'Check the loop length in frames entered by the user
			Call MsgBox("Recap Loop must be between 5 and 500 frames", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "Helium Frog Animator")
			Exit Sub
		End If
		
		If (Int(Val(Me.txtJpegQuality.Text)) > 100) Or (Int(Val(Me.txtJpegQuality.Text)) < 1) Then 'Check the Jpeg Quality is between 1 and 100
			Call MsgBox("Jpeg Quality setting must be between 1% and 100%", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "Helium Frog Animator")
			Exit Sub
		End If
		
		If (Int(Val(Me.txtCaptureQuality.Text)) > 100) Or (Int(Val(Me.txtCaptureQuality.Text)) < 1) Then 'Check the Jpeg capture Quality is between 1 and 100
			Call MsgBox("Capture Quality setting must be between 1% and 100%", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "Helium Frog Animator")
			Exit Sub
		End If
		
		If (Int(Val(Me.txtFramesPerClick.Text)) > 5) Or (Int(Val(Me.txtFramesPerClick.Text)) < 1) Then 'Check the Frames per click is between 1 and 5
			Call MsgBox("The number of frames captured per shutter click must be between 1 and 5", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "Helium Frog Animator")
			Exit Sub
		End If
		
		If Me.chkSafeArea.CheckState = 1 Then 'set variable of whether the user wants a safe area rectangle or not
			SafeAreaYesNo = True
		Else
			SafeAreaYesNo = False
		End If
		
		SafeAreaWidth = CInt(Val(Me.txtSafeAreaWidth.Text))
		If SafeAreaWidth < 50 Then SafeAreaWidth = 50
		If SafeAreaWidth > CaptureWidth Then SafeAreaWidth = CaptureWidth
		
		SafeAreaHeight = CInt(Val(Me.txtSafeAreaHeight.Text))
		If SafeAreaHeight < 50 Then SafeAreaHeight = 50
		If SafeAreaHeight > CaptureHeight Then SafeAreaHeight = CaptureHeight
		
		'Set the hotkeys
		Ascii01 = CInt(Val(Me.txtHotkey01.Text))
		If (Ascii01 < 1) Or (Ascii01 > 255) Then
			Call MsgBox("Hotkey Capture 1 invalid" & Chr(13) & "Ascii codes must be between 1 and 255", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "Helium Frog Animator")
			Exit Sub
		End If
		
		Ascii02 = CInt(Val(Me.txtHotkey02.Text))
		If (Ascii02 < 1) Or (Ascii02 > 255) Then
			Call MsgBox("Hotkey Capture 2 invalid" & Chr(13) & "Ascii codes must be between 1 and 255", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "Helium Frog Animator")
			Exit Sub
		End If
		
		Ascii03 = CInt(Val(Me.txtHotkey03.Text))
		If (Ascii03 < 1) Or (Ascii03 > 255) Then
			Call MsgBox("Hotkey To Start invalid" & Chr(13) & "Ascii codes must be between 1 and 255", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "Helium Frog Animator")
			Exit Sub
		End If
		
		Ascii04 = CInt(Val(Me.txtHotkey04.Text))
		If (Ascii04 < 1) Or (Ascii04 > 255) Then
			Call MsgBox("Hotkey Back 1 invalid" & Chr(13) & "Ascii codes must be between 1 and 255", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "Helium Frog Animator")
			Exit Sub
		End If
		
		Ascii05 = CInt(Val(Me.txtHotkey05.Text))
		If (Ascii05 < 1) Or (Ascii05 > 255) Then
			Call MsgBox("Hotkey Stop invalid" & Chr(13) & "Ascii codes must be between 1 and 255", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "Helium Frog Animator")
			Exit Sub
		End If
		
		Ascii06 = CInt(Val(Me.txtHotkey06.Text))
		If (Ascii06 < 1) Or (Ascii06 > 255) Then
			Call MsgBox("Hotkey Play invalid" & Chr(13) & "Ascii codes must be between 1 and 255", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "Helium Frog Animator")
			Exit Sub
		End If
		
		Ascii07 = CInt(Val(Me.txtHotkey07.Text))
		If (Ascii07 < 1) Or (Ascii07 > 255) Then
			Call MsgBox("Hotkey Forward 1 invalid" & Chr(13) & "Ascii codes must be between 1 and 255", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "Helium Frog Animator")
			Exit Sub
		End If
		
		Ascii08 = CInt(Val(Me.txtHotkey08.Text))
		If (Ascii08 < 1) Or (Ascii08 > 255) Then
			Call MsgBox("Hotkey To End invalid" & Chr(13) & "Ascii codes must be between 1 and 255", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "Helium Frog Animator")
			Exit Sub
		End If
		
		Ascii09 = CInt(Val(Me.txtHotkey09.Text))
		If (Ascii09 < 1) Or (Ascii09 > 255) Then
			Call MsgBox("Hotkey Loop invalid" & Chr(13) & "Ascii codes must be between 1 and 255", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "Helium Frog Animator")
			Exit Sub
		End If
		
		Ascii10 = CInt(Val(Me.txtHotkey10.Text))
		If (Ascii10 < 1) Or (Ascii10 > 255) Then
			Call MsgBox("Hotkey Exit invalid" & Chr(13) & "Ascii codes must be between 1 and 255", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "Helium Frog Animator")
			Exit Sub
		End If
		
		Ascii11 = CInt(Val(Me.txtHotkey11.Text))
		If (Ascii11 < 1) Or (Ascii11 > 255) Then
			Call MsgBox("Hotkey Toggle Live invalid" & Chr(13) & "Ascii codes must be between 1 and 255", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "Helium Frog Animator")
			Exit Sub
		End If
		
		Ascii12 = CInt(Val(Me.txtHotkey12.Text))
		If (Ascii12 < 1) Or (Ascii12 > 255) Then
			Call MsgBox("Hotkey Open invalid" & Chr(13) & "Ascii codes must be between 1 and 255", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "Helium Frog Animator")
			Exit Sub
		End If
		
		Ascii13 = CInt(Val(Me.txtHotkey13.Text))
		If (Ascii13 < 1) Or (Ascii13 > 255) Then
			Call MsgBox("Hotkey Onion Skin invalid" & Chr(13) & "Ascii codes must be between 1 and 255", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "Helium Frog Animator")
			Exit Sub
		End If
		
		Ascii14 = CInt(Val(Me.txtHotKey14.Text))
		If (Ascii14 < 1) Or (Ascii14 > 255) Then
			Call MsgBox("Hotkey Settings invalid" & Chr(13) & "Ascii codes must be between 1 and 255", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "Helium Frog Animator")
			Exit Sub
		End If
		
		Ascii15 = CInt(Val(Me.txtHotKey15.Text))
		If (Ascii15 < 1) Or (Ascii15 > 255) Then
			Call MsgBox("Hotkey Utilities invalid" & Chr(13) & "Ascii codes must be between 1 and 255", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "Helium Frog Animator")
			Exit Sub
		End If
		
		Ascii16 = CInt(Val(Me.txtHotkey16.Text))
		If (Ascii16 < 1) Or (Ascii16 > 255) Then
			Call MsgBox("Hotkey Editor invalid" & Chr(13) & "Ascii codes must be between 1 and 255", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "Helium Frog Animator")
			Exit Sub
		End If
		
		Ascii17 = CInt(Val(Me.txtHotkey17.Text))
		If (Ascii17 < 1) Or (Ascii17 > 255) Then
			Call MsgBox("Hotkey Rotoscope invalid" & Chr(13) & "Ascii codes must be between 1 and 255", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "Helium Frog Animator")
			Exit Sub
		End If
		
		Ascii18 = CInt(Val(Me.txtHotkey18.Text))
		If (Ascii18 < 1) Or (Ascii18 > 255) Then
			Call MsgBox("Hotkey Undo invalid" & Chr(13) & "Ascii codes must be between 1 and 255", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "Helium Frog Animator")
			Exit Sub
		End If
		
		CaptureQuality = (Int(Val(Me.txtCaptureQuality.Text))) 'Set the jpeg quality of the frames that are to be appended to the avi file.
		If CaptureQuality < 1 Then CaptureQuality = 1
		If CaptureQuality > 100 Then CaptureQuality = 100
		
		LoopLength = Int(Val(Me.txtLoopLength.Text)) 'Set the loop length to what has been input by the user
		
		CaptureSound = Me.txtCaptureSnd.Text 'Set the capture sound to what has been entered by the user
		Call LoadSound() 'Load in the sound again as it may have changed
		FPS = Int(Val(Me.txtFPS.Text)) 'Sets the frames per second to that input by the user
		
		TimeLapseDelay = Int(Val(Me.txtTimeLapseDelay.Text) * 1000) 'Sets the time lapse interval
		
		FrameAvgDepth = Int(Val(Me.txtFrameDpth.Text)) 'Sets the number of frames that are sampled at capture to that entered by the user
		FrameAvgDelay = Int(Val(Me.txtFrameDel.Text)) 'Sets the delay time between frames that are sampled at capture to that entered by the user
		
		XSheetOffset = Int(Val(Me.txtXSheetOffset.Text)) 'Set the xsheet offset variable
		
		
		If Me.chkIndBmps.CheckState = 1 Then 'Set variable if the user wants to output individual bitmaps for each frame
			OutputBmpFramesYesNo = True
		Else
			OutputBmpFramesYesNo = False
		End If
		
		If Me.chkIndJpegs.CheckState = 1 Then 'Set variable if the user wants to output individualjpegs for each frame
			OutputJpgFramesYesNo = True
		Else
			OutputJpgFramesYesNo = False
		End If
		
		If Me.chkIndTifs.CheckState = 1 Then 'Set variable if the user wants to output individual tiff for each frame
			OutputTifFramesYesNo = True
		Else
			OutputTifFramesYesNo = False
		End If
		
		If Me.chkIndGifs.CheckState = 1 Then 'Set variable if the user wants to output individual gif for each frame
			OutputGifFramesYesNo = True
		Else
			OutputGifFramesYesNo = False
		End If
		
		If Me.chkIndPngs.CheckState = 1 Then 'Set variable if the user wants to output individual png for each frame
			OutputPngFramesYesNo = True
		Else
			OutputPngFramesYesNo = False
		End If
		
		
		If optOff.Checked = True Then
			ChromaType = "Off"
			ChromaKeyingYesNO = False
		End If
		
		If optRed.Checked = True Then
			ChromaType = "Red"
			ChromaKeyingYesNO = True
		End If
		
		If OptGreen.Checked = True Then
			ChromaType = "Green"
			ChromaKeyingYesNO = True
		End If
		
		If optBlue.Checked = True Then
			ChromaType = "Blue"
			ChromaKeyingYesNO = True
		End If
		
		'UPGRADE_WARNING: Dir has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
		If Dir(txtBackground.Text) = "" Or Len(txtBackground.Text) = 0 Then 'if the file doesn't exist reset to default name (may be user has hit cancel button whilst selecting)
			ChromaBackground = "No Background Image Selected"
			ChromaKeyingYesNO = False
			ChromaType = "Off" 'switch chroma keying off
		Else
			ChromaBackground = txtBackground.Text
			frmAveraging.picBackground.Image = System.Drawing.Image.FromFile(ChromaBackground) 'Load the picture into the background picturebox ready for chroma keying
		End If
		
		
		If Me.chkFrameStamp.CheckState = 1 Then 'Set variable if the user wants to have the frame numbers stamped on the bitmaps.
			FrameNumberStampYesNo = True
		Else
			FrameNumberStampYesNo = False
		End If
		
		JpegQuality = (Int(Val(Me.txtJpegQuality.Text))) 'Set the jpeg quality variable
		If JpegQuality < 1 Then JpegQuality = 1
		If JpegQuality > 100 Then JpegQuality = 100
		
		If Me.chkSoundSwitch.CheckState = 1 Then 'Set variable if the user wants to have sound on or off
			SoundsOnOff = True
		Else
			SoundsOnOff = False
		End If
		
		If Me.chkMouthShapes.CheckState = 1 Then 'Set variable if the user wants to have mouth displayed or not
			MouthShapeOnOff = True
		Else
			MouthShapeOnOff = False
		End If
		Call frmXSheet.MouthShapeSwitch() 'switch the mouth on or off
		
		NumFramesPerClick = Int(Val(Me.txtFramesPerClick.Text)) 'Sets the number of frames captured per click to that input by the user
		
		If Me.chkCaptureMacro.CheckState = 1 Then 'Set variable if the user wants to use the capture macro
			ShutterMacroYesNo = True
		Else
			ShutterMacroYesNo = False
		End If
		If Me.txtMacroFile.Text <> "" Then 'If macro filename has a value in it
			MacroFilename = Me.txtMacroFile.Text 'Set the macro filename to that chosen by the user
		Else
			MacroFilename = "Select Macro filename" 'Set the filename to show that the user needs to put in an output
		End If
		
		If Me.chkErrorLogging.CheckState = 1 Then 'check the variable to see if the user wants to output an error logging text file
			ErrorLoggingYesNO = True
		Else
			ErrorLoggingYesNO = False
		End If
		
		'UPGRADE_WARNING: Dir has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
		If Dir(txtSoundTrack.Text) = "" Or Len(txtSoundTrack.Text) = 0 Then 'if the file doesn't exist reset to default name (may be user has hit cancel button whilst selecting)
			SoundTrackName = "No Soundtrack Selected"
		Else
			SoundTrackName = txtSoundTrack.Text
		End If
		
		Call AudioPlayer_Create(SoundTrackName) 'Setup / reset  the soundtrack audio player
		
		If Len(Me.txtProjName.Text) = 0 Then
			Call MsgBox("There is no Valid Project Name", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "Helium Frog Animator")
			Exit Sub
		End If
		
		If Len(Me.txtSaveDir.Text) = 0 Then
			Call MsgBox("There is no Valid Save Directory", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "Helium Frog Animator")
			Exit Sub
		End If
		
		
		'****************could check here if the exposuresheet has changed, it may save time rather tahn reload it each time.
		
		
		'UPGRADE_WARNING: Dir has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
		If Dir(txtXSheet.Text) = "" Or Len(txtXSheet.Text) = 0 Then 'if the file doesn't exist reset to default name (may be user has hit cancel button whilst selecting)
			XSheetName = "No X Sheet Selected"
		Else
			XSheetName = txtXSheet.Text
		End If
		
		
		
		
		'Continue with current animation
		If (ProjName = Me.txtProjName.Text) And (SavePath = Me.txtSaveDir.Text) Then 'If no changes have been made to the file name or directory
			ActiveWindowIs = "ButtonWindow" 'Make Buttons window active again so buttons and hotkeys will now work again
			Me.Visible = False 'Hide the settings form
			GoTo ReadyToLeave
		End If
		
		'Begin a new animation
		'UPGRADE_WARNING: Dir has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
		If Dir(Me.txtSaveDir.Text & Me.txtProjName.Text & ".avi") = "" Then 'If the file doesnt exist the user wants to start a new animation
			If MsgBox("This file has not been created, do you want to begin a new animation?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Helium Frog Animator") = MsgBoxResult.Yes Then
				'The user wants to start a new animation
				ProjName = Me.txtProjName.Text 'Set the save name to what has been entered by the user
				SavePath = Me.txtSaveDir.Text 'Set the save path to what has been entered by the user
				FrameNum = 0 'Set the number of frames back to zero
				ActiveWindowIs = "ButtonWindow" 'Make Buttons window active again so buttons and hotkeys will now work again
				Me.Visible = False 'Hide the settings form
				GoTo ReadyToLeave
			Else
				'The user wants to continue on with the current animation
				Me.txtProjName.Text = ProjName 'Reset the project name back to what it was
				Me.txtSaveDir.Text = SavePath 'Reset the save directory back to what it was
				FunctionOK = OpenDShowPlayBack(SavePath & ProjName & ".avi", (frmCapture.picPlayBack)) 'Open up the video
				GoTo ReadyToLeave
			End If
		End If
		
		
		'Modify an existing animation
		'UPGRADE_WARNING: Dir has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
		If Dir(Me.txtSaveDir.Text & Me.txtProjName.Text & ".avi") <> "" Then 'If the file exists on disk
			If MsgBox("Do you want to add to this existing file?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Helium Frog Animator") = MsgBoxResult.Yes Then
				'          'The user wants to add to an existing file
				
				ProjName = Me.txtProjName.Text 'Set the save name to what has been entered by the user
				SavePath = Me.txtSaveDir.Text 'Set the save path to what has been entered by the user
				FileOpen(18, SavePath & ProjName & ".avi", OpenMode.Binary, OpenAccess.Read)
				'UPGRADE_WARNING: Get was upgraded to FileGet and has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
				FileGet(18, FrameNum, 48 + 1) 'Get the total number of frames as specified in the header
				FileClose(18)
				RemoveDShowPlayBack() 'stop the current video playback
				FunctionOK = OpenDShowPlayBack(SavePath & ProjName & ".avi", (frmCapture.picPlayBack)) 'Load the new video in the playback window
				If ExtractSingleFrame(SavePath & ProjName & ".avi", -999, My.Application.Info.DirectoryPath & "\Undo.jpg") = True Then 'Extract the last frame available for onion skin
					frmAveraging.picOnion1.Image = System.Drawing.Image.FromFile(My.Application.Info.DirectoryPath & "\Undo.jpg") 'Load the picture into the onion buffer
				Else
					Call MsgBox("I failed to extract the last frame for the onion skin routine", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "Helium Frog Animator")
				End If
				
				ActiveWindowIs = "ButtonWindow" 'Make Buttons window active again so buttons and hotkeys will now work again
				Me.Visible = False 'Hide the settings form
				Me.txtProjName.Text = ProjName 'Get the project name from the text box
				Me.txtSaveDir.Text = SavePath 'Get the save directory from the text box
				FunctionOK = OpenDShowPlayBack(SavePath & ProjName & ".avi", (frmCapture.picPlayBack)) 'Open up the video
				GoTo ReadyToLeave
			Else
				'The user wants to continue on with the current animation
				Me.txtProjName.Text = ProjName 'Get the project name from the text box
				Me.txtSaveDir.Text = SavePath 'Get the save directory from the text box
				FunctionOK = OpenDShowPlayBack(SavePath & ProjName & ".avi", (frmCapture.picPlayBack)) 'Open up the video
				GoTo ReadyToLeave
			End If
		End If
		
ReadyToLeave: 
		
		ExposureTopPos = FrameNum 'set the top position of the exposure sheet to the frame
		Call frmXSheet.ReloadExposureSheet(ExposureTopPos) 'reprint the form
		
	End Sub
	
	
	'UPGRADE_ISSUE: PictureBox event picFacia2.KeyDown was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="ABD9AF39-7E24-4AFF-AD8D-3675C1AA3054"'
	Private Sub picFacia2_KeyDown(ByRef KeyCode As Short, ByRef Shift As Short) 'if the user has focus on the form area, this prints the ascii code in the box
		lblAsciiCodeFinder.Text = "Last Keypress = Ascii Code " & KeyCode
	End Sub
End Class